package com.lighthouse.issue.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.UUID;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 问题对象 lh_base_issue
 * 
 * @author ysz
 * @date 2024-02-03
 */
@Document(indexName = "issue-info-000001")
@Data
public class KnowledgeIssue
{
    private static final long serialVersionUID = 1L;

    /** 文档主键 */
    @Id
    @Field(type = FieldType.Keyword)
    private String issueId;

    /** 问题名称 */
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String issueName;

    /** 标签 */
    @Field(type = FieldType.Text)
    private String issueTags;

    /** 标签名称 */
    @Field(type = FieldType.Text)
    private List<String> issueTagsName;

    /** 问题描述 */
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String issueDesc;

    /** 浏览量 */
    @Field(type = FieldType.Keyword)
    private Long issueViews;

    /** 点赞量 */
    @Field(type = FieldType.Keyword)
    private Long issueLikes;

    /** 收藏量 */
    @Field(type = FieldType.Keyword)
    private Long issueCollects;

    /** 评论量 */
    @Field(type = FieldType.Keyword)
    private Long issueComments;

    /** 发布状态  0-草稿  1-待审核  2-已发布  3-存档  4-已删除*/
    @Field(type = FieldType.Keyword)
    private String issueStatus;

    /** 解决状态  1-已解决  0-未解决*/
    @Field(type = FieldType.Keyword)
    private String issueSolveStatus;

    /** 问题场景 */
    @Field(type = FieldType.Keyword)
    private String issueScene;

    /** 问题原因 */
    @Field(type = FieldType.Keyword)
    private String issueCause;

    /** 问题解决方案 */
    @Field(type = FieldType.Keyword)
    private String issueSolution;

    /** 问题类型 */
    @Field(type = FieldType.Keyword)
    private String issueType;

    /** 问题所属产品 */
    @Field(type = FieldType.Keyword)
    private String issueBelongProduct;

    /** 问题所属产品版本 */
    @Field(type = FieldType.Keyword)
    private String issueBelongVersion;

    @Field(type = FieldType.Keyword)
    private String createBy;

    @Field(type = FieldType.Date, format = DateFormat.date)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate createTime;

    @Field(type = FieldType.Keyword)
    private String updateBy;

    @Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second_millis)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;

    @Field(type = FieldType.Long)
    private Long createUser;

    @Field(type = FieldType.Keyword)
    private String createUserAvatar;

    public String getIssueId() {
        return issueId;
    }

    public void setIssueId(String issueId) {
        this.issueId = issueId;
    }

    public String getIssueName() {
        return issueName;
    }

    public void setIssueName(String issueName) {
        this.issueName = issueName;
    }

    public String getIssueTags() {
        return issueTags;
    }

    public void setIssueTags(String issueTags) {
        this.issueTags = issueTags;
    }

    public List<String> getIssueTagsName() {
        return issueTagsName;
    }

    public void setIssueTagsName(List<String> issueTagsName) {
        this.issueTagsName = issueTagsName;
    }

    public String getIssueDesc() {
        return issueDesc;
    }

    public void setIssueDesc(String issueDesc) {
        this.issueDesc = issueDesc;
    }

    public Long getIssueViews() {
        return issueViews;
    }

    public void setIssueViews(Long issueViews) {
        this.issueViews = issueViews;
    }

    public Long getIssueLikes() {
        return issueLikes;
    }

    public void setIssueLikes(Long issueLikes) {
        this.issueLikes = issueLikes;
    }

    public Long getIssueCollects() {
        return issueCollects;
    }

    public void setIssueCollects(Long issueCollects) {
        this.issueCollects = issueCollects;
    }

    public Long getIssueComments() {
        return issueComments;
    }

    public void setIssueComments(Long issueComments) {
        this.issueComments = issueComments;
    }

    public String getIssueStatus() {
        return issueStatus;
    }

    public void setIssueStatus(String issueStatus) {
        this.issueStatus = issueStatus;
    }

    public String getIssueSolveStatus() {
        return issueSolveStatus;
    }

    public void setIssueSolveStatus(String issueSolveStatus) {
        this.issueSolveStatus = issueSolveStatus;
    }

    public String getIssueScene() {
        return issueScene;
    }

    public void setIssueScene(String issueScene) {
        this.issueScene = issueScene;
    }

    public String getIssueCause() {
        return issueCause;
    }

    public void setIssueCause(String issueCause) {
        this.issueCause = issueCause;
    }

    public String getIssueSolution() {
        return issueSolution;
    }

    public void setIssueSolution(String issueSolution) {
        this.issueSolution = issueSolution;
    }

    public String getIssueType() {
        return issueType;
    }

    public void setIssueType(String issueType) {
        this.issueType = issueType;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public LocalDate getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDate createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Long getCreateUser() {
        return createUser;
    }

    public void setCreateUser(Long createUser) {
        this.createUser = createUser;
    }

    public String getCreateUserAvatar() {
        return createUserAvatar;
    }

    public void setCreateUserAvatar(String createUserAvatar) {
        this.createUserAvatar = createUserAvatar;
    }

    public String getIssueBelongProduct() {
        return issueBelongProduct;
    }

    public void setIssueBelongProduct(String issueBelongProduct) {
        this.issueBelongProduct = issueBelongProduct;
    }

    public String getIssueBelongVersion() {
        return issueBelongVersion;
    }

    public void setIssueBelongVersion(String issueBelongVersion) {
        this.issueBelongVersion = issueBelongVersion;
    }

    @Override
    public String toString() {
        return "KnowledgeIssue{" +
                "issueId='" + issueId + '\'' +
                ", issueName='" + issueName + '\'' +
                ", issueTags=" + issueTags +
                ", issueTagsName=" + issueTagsName +
                ", issueDesc='" + issueDesc + '\'' +
                ", issueViews=" + issueViews +
                ", issueLikes=" + issueLikes +
                ", issueCollects=" + issueCollects +
                ", issueComments=" + issueComments +
                ", issueStatus='" + issueStatus + '\'' +
                ", issueSolveStatus='" + issueSolveStatus + '\'' +
                ", issueScene='" + issueScene + '\'' +
                ", issueCause='" + issueCause + '\'' +
                ", issueSolution='" + issueSolution + '\'' +
                ", issueType='" + issueType + '\'' +
                ", createBy='" + createBy + '\'' +
                ", createTime=" + createTime +
                ", updateBy='" + updateBy + '\'' +
                ", updateTime=" + updateTime +
                ", createUser=" + createUser +
                ", createUserAvatar='" + createUserAvatar + '\'' +
                ", issueBelongProduct='" + issueBelongProduct + '\'' +
                ", issueBelongVersion='" + issueBelongVersion + '\'' +
                '}';
    }

    public void setCreateInfo() {
        this.issueId = UUID.fastUUID().toString();
        this.createBy = SecurityUtils.getLoginUser().getUser().getNickName();
        this.createTime = LocalDate.now();
        this.createUser = SecurityUtils.getLoginUser().getUser().getUserId();
        this.createUserAvatar = SecurityUtils.getLoginUser().getUser().getAvatar();
        this.issueViews = 1L;
        this.issueLikes = 0L;
        this.issueCollects = 0L;
        this.issueComments = 0L;
    }

    public void setUpdateInfo() {
        this.updateBy = SecurityUtils.getLoginUser().getUser().getNickName();
        this.updateTime = LocalDateTime.now();
    }
}
